# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php81-pecl-brotli
_extname=brotli
pkgver=0.15.0
pkgrel=2
pkgdesc="Brotli Extension for PHP 8.1"
url="https://github.com/kjdev/php-ext-brotli"
arch="all"
license="MIT"
_phpv=81
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev $_php-pecl-apcu brotli-dev"
checkdepends="$_php-cgi"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir/$_extname-$pkgver"

provides="$_php-brotli=$pkgver-r$pkgrel" # for backward compatibility
replaces="$_php-brotli" # for backward compatibility
install_if="php-$_extname $_php"

build() {
	phpize$_phpv
	./configure \
		--prefix=/usr \
		--with-php-config=php-config$_phpv \
		--with-libbrotli # Use system lib
	make
}

check() {
	local _modules=/usr/lib/$_php/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 SKIP_ONLINE_TESTS=1 test \
		TEST_PHP_CGI_EXECUTABLE=/usr/bin/php-cgi$_phpv \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/apcu.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/50_$_extname.ini
}

sha512sums="
0e3be424eace7ed50f67dac780fa55c0fa6da1265676cea12588d8713ec6636936379a543bde48f7b30054aeda038200a3f650259e2da589f642447125b32e6a  php-pecl-brotli-0.15.0.tgz
"
